Chen Yulin's BlogChen Yulin's Blog
HomeArchivesCategoriesTagsAbout
  目录
Posted 2025-07-14Updated 2026-02-22Note5 minutes read (About 786 words)   visits

Math6003 Hw5

Homework 5 Report

Zhichen Tang
124370910020


Exercise 1

In this first part, I looked at the logistic model for population growth. The main goal was to solve the equation $u’(t) = C u(t) (1 - u(t)/B)$ using a couple of different numerical methods. The parameters were set to $u_0=100$, $B=1000$, and $C=2/15$.

a)

I take the current value and add the slope at that point multiplied by the time step to get the next value.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
% Completed feuler.m
function [t, u, dt] = feuler( f, I, u0, N )
dt = (I(2)-I(1))/N;
t = linspace(I(1),I(2),N+1);
u = zeros(1,N+1);
u(1) = u0;
for n = 1:N
u(n+1) = u(n) + dt * f(t(n), u(n));
end
end
````


### b)
First, I calculated a temporary "predicted" value (just like a standard Euler step). Then, I averaged the slope at the current point and the slope at the next point (using the predicted value) to get a more accurate step.

Matlab

% Completed heun.m
function [t, u, dt] = heun( f, I, u0, N )
dt = (I(2)-I(1))/N;
t = linspace(I(1),I(2),N+1);
u = zeros(1,N+1);
u(1) = u0;
for n = 1:N
u_predictor = u(n) + dt * f(t(n), u(n));
u(n+1) = u(n) + (dt/2) * ( f(t(n), u(n)) + f(t(n+1), u_predictor) );
end
end


<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex1b.png" alt="" title=""></div>
### c) 

After implementing the methods, I ran them with a coarse time step (Deltat=5, corresponding to N=20) and plotted them against the exact solution.

It's pretty clear from the graph that the Heun method does a much better job. Its curve hugs the exact solution line much more tightly than the Forward Euler curve does. This makes sense because it's a higher-order method, so you'd expect it to be more accurate for the same step size.

<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex1c.png" alt="" title=""></div>

### d)

Next, I repeated the comparison but with a much smaller time step (Deltat=0.05, or N=2000).


Absolutely. With the smaller time step, both methods improved dramatically. The plot shows that the lines for the Euler method, Heun's method, and the exact solution are basically right on top of each other. This really shows how decreasing the step size can significantly reduce the error in numerical solutions. However, the Heun method's absolute error is still lower than the Euler method.

<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex1d.png" alt="" title=""></div>

---

## Exercise 2

### a)

To solve this, I first had to convert the single 2nd-order equation into a system of two 1st-order equations. I defined a new variable, V(t)=U′(t). This gives the first equation of the system.

Then, I rearranged the original RLC equation to isolate U′′(t):

$$ U''(t) = -\frac{R}{L}U'(t) - \frac{1}{LC}U(t) + \frac{f}{LC} $$

By substituting V for U′ and V′ for U′′, I got the second equation. This allowed me to write the whole system in matrix form, X′=AX+b:

$$\begin{pmatrix} V' \\ U' \end{pmatrix} = \begin{pmatrix} -R/L & -1/(LC) \\ 1 & 0 \end{pmatrix} \begin{pmatrix} V \\ U \end{pmatrix} + \begin{pmatrix} f/(LC) \\ 0 \end{pmatrix} $$
### b)
Stability Analysis of Forward Euler The Forward Euler method is only stable if $|1 + \Delta t \lambda_i| \le 1$ for all eigenvalues ($\lambda_i$) of the matrix A. Using the given component values (L=0.01, C=10, R=0.1), the matrix A becomes: $$ A = \begin{pmatrix} -10 & -10 \\ 1 & 0 \end{pmatrix} $$ I calculated the eigenvalues to be $\lambda = -5 \pm \sqrt{15}$. To ensure stability, the time step $\Delta t$ has to be less than a critical value determined by the eigenvalue with the largest magnitude. The calculation showed that the method is stable only if: $$ \Delta t \le \frac{2}{5 + \sqrt{15}} \approx 0.2254 \text{ s} $$
### c) 
Simulating with Forward Euler I ran simulations for three different time steps. The results were a perfect illustration of the stability condition. 
<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex2c.png" alt="" title=""></div>
As you can see: - With **N=43** ($\Delta t \approx 0.233$), the time step was too large, and the solution completely blew up. - With **N=46** ($\Delta t \approx 0.217$), the time step was just inside the stable range, and the solution correctly showed a damped wave. - With **N=500** ($\Delta t = 0.02$), the solution was also stable and much smoother. 
### d)
Simulating with Backward Euler Finally, I repeated the same simulations using the Backward Euler method. 
<div class="post-content"><img src="/2025/07/14/[OBS]课程-Math6003 Hw5/ex2d.png" alt="" title=""></div>
The difference is night and day. The Backward Euler method was **stable for all three time steps**, even the large one that made the Forward Euler method fail. This shows that implicit methods like Backward Euler are much more robust for systems like this, as they don't have the same strict stability requirements on the time step. While the accuracy still gets better with smaller steps, you can trust it to give a stable answer no matter what.

Math6003 Hw5

http://chen-yulin.github.io/2025/07/14/[OBS]课程-Math6003 Hw5/

Author

Chen Yulin

Posted on

2025-07-14

Updated on

2026-02-22

Licensed under

MATH6003J Project Proposal
Use SSH to Connect TensorboardX

Comments

Chen Yulin

Chen Yulin

SJTU student

Manchester by the Sea

Posts

312

Categories

10

Tags

235

Follow

Catalogue

  • Homework 5 Report
    • Exercise 1
      • a)

Archives

  • February 202611
  • January 20268
  • December 20253
  • November 20256
  • October 20251
  • September 20253
  • August 20256
  • July 20255
  • June 20256
  • May 202510
  • April 202517
  • March 202545
  • February 202512
  • January 202513
  • December 202412
  • November 20244
  • October 202418
  • September 202416
  • August 202413
  • July 20243
  • June 20245
  • May 202413
  • April 202417
  • March 20241
  • January 20241
  • December 20231
  • May 202346
  • August 20221
  • May 20226
  • April 20229

Recents

exist_label

2026-02-14

exist_label

Note

BAGEL-Unified-Multimodal-Pretraining

2026-02-06

BAGEL-Unified-Multimodal-Pretraining

Review

LingBot-VLA

2026-02-05

LingBot-VLA

Review

Mixture-of-Experts-Survey

2026-02-05

Mixture-of-Experts-Survey

Review

2026-02-05

人形机器人控制方法综述

Note

Tags

3D-Scene17
6-D3
AI16
AIGC1
API1
AR2
Academic1
Algorithm1
Aliyun1
App2
Atlas1
BS41
Bayesian-Inference1
Beautify1
Behaviorism1
Business1
C1
CADC1
CD1
CLI1
CLIP11
CNN1
CV68
Camera1
Capstone10
Chemistry1
Claude1
Communication2
Contrastive-Learning5
Control3
Csharp9
Css1
Cuda3
DD1
DINO4
DT1
Dataframe1
Debate5
Debugger1
Deep-Learning1
Development-Tools1
Diffusion2
Diffusion-Policy1
DiffusionModel4
Discrete-Mathematics1
Disney1
Docker1
Docs2
Dynamic-programming1
ESP322
Education1
Embeded-System9
Embodied-AI19
Emoation1
Emotion13
Ethic1
Experiment2
FL1
FPN2
Family1
Federated-Learning1
Foundation1
FoundationModel4
Functional programming1
GPT3
Game5
Gated-NN3
Git7
Github1
Godot3
Graph1
HPC1
HRI2
Haskell1
Health2
Hexo10
Hierarchical4
Html5
Humanism1
Humanoid1
HumanoidRobot1
Hybrid-Control1
Hyprland2
IK1
Image-Grounding2
Image-Text4
Image-generation2
Image2Text7
ImgGen3
ImitationLearning5
Information-Theory1
Jolt1
Json1
LLM17
LSP2
LatentAction1
Latex2
Lego1
Life4
LinearAlgebra1
Linux22
Live2d1
Love4
Lua1
MBTI1
ML14
MPC2
MR/AR3
Machine-Learning3
Mason1
Math7
Meme1
Message-Passing2
MindPlus1
MoE2
Mod3
Model-Predictive-Control1
Motivation1
Moveit1
Movie1
Multi-Agent1
Multi-modal14
Multi-view1
MultiModal5
Music5
NLP6
NN12
Network2
Nodejs5
Numpy1
Nvim9
Object-Detection9
Open-Vocabulary11
OpenCV1
Oral1
PHD1
PSY5
Pandas2
Panoptic1
Path1
Philosophy3
PhysX1
Physical-Scene4
Physics-engine1
Pio2
Planning1
Plugin8
PoseEstimation3
Postgraduate1
Prefab1
Probability2
Python30
Pytorch1
QML1
Quantum1
RAG1
RL3
RNN4
ROS6
Reading19
Real2Sim2
Reconstruct13
Regex2
Reinforcement-Learning2
Reinforcement-learning1
Repository5
Representation-Learning5
Research-paper97
Robot5
RobotLearning13
Robotics38
SJTU-Lecture1
SQL2
SSH3
Scalability2
Scene-graph34
Scene-synthesis2
Science-fiction1
Scrap1
Script2
Segmentation8
Semantic15
Shader3
Shell4
Signals and Systems1
Sim2Real1
Sklearn1
Snippets1
Society4
Star-rail1
Statistics2
Subgraph1
Submodule1
Supervised-learning2
Survey4
TC1
TOEFL1
Task-Planning9
Tasks5
Tech Communication1
Torch5
Transformer20
Translation-Embedding2
Travel5
UI1
Unified-Multimodal1
Unity20
Unsupervised-learning1
VAE2
VLA4
VLM9
VLP5
VQ-VAE1
Variational-Inference1
Version-management1
ViT5
VideoEditing2
Vim1
Visual-Relation23
WSL1
Waybar1
Wayland1
Web1
Website1
Well-being1
Window-manager2
WorldModel2
YKLL3
Zen2
♥️2
实习1
🍢1
🍰1
🐱2
🧀1
Chen Yulin's BlogChen Yulin's Blog

© 2026 Chen Yulin  Powered by Hexo & Icarus

×